#
# minimal MetaROUTER app example - Makefile
#
#  Copyright (C) 2013 Peter Lawrence
#
#  All rights reserved.
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License version 2.1, as
#  published by the Free Software Foundation.  This program is
#  distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
#  License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with this program; if not, see <http://www.gnu.org/licenses/>.


# adjust this to your cross-compiler path of choice
TC_PREFIX := ~/toolchain/bin/mips-linux-

ALL: test.tgz

TINCAN_OBJS := start.o main.o hypercalls.o console.o veth.o peek.o

%.o: %.c Makefile
	$(TC_PREFIX)gcc -c -march=24kc -fno-pic -mno-abicalls -mlong-calls $< -o $@

%.o: %.S Makefile
	$(TC_PREFIX)as -march=24kc $< -o $@

kernel: $(TINCAN_OBJS) Makefile
	$(TC_PREFIX)ld $(TINCAN_OBJS) -l c -T tincan.lds -o tincan.elf
	$(TC_PREFIX)strip tincan.elf -o kernel

test.tgz: kernel
	tar czf test.tgz ./kernel

clean:
	rm -f *.o
	rm -f *.elf
	rm -f kernel test.tgz

